package com.hibernate.relationship;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import com.hibernate.relationship.vo.Email;

public class OneToOneExample {

	private static SessionFactory factory = new Configuration().configure().buildSessionFactory();
	private static Session session;

	public static void main(String[] args) {

		session = factory.openSession();
		Email e = (Email) session.get(Email.class, 2);
		System.out.println("Id=" + e.getId() + ",Title=" + e.getTitle());
//		System.out.println("msgText=" + e.getMessage().getMessageText());
		// Comment to test lazy load
		
		session.close();
		System.out.println("msgText=" + e.getMessage());
	}
}
